package com.c.characteristic.lianxi;

public class TestEmployee {

    public static void main(String[] args) {

        SalariedEmployee salariedEmployee=new SalariedEmployee();   //固定工资员工
        salariedEmployee.setName("张三");
        salariedEmployee.setMonth(8);
        salariedEmployee.setSalary(5000);
        salariedEmployee.getSalary(8);                       //计算8月份的工资

        HourlyEmployee hourlyEmployee=new HourlyEmployee();
        hourlyEmployee.setName("李四");
        hourlyEmployee.setMonth(6);
        hourlyEmployee.setHours(190);
        hourlyEmployee.setHourlySalary(20);
        hourlyEmployee.getSalary(8);

        SalesEmployee salesEmployee=new SalesEmployee();
        salesEmployee.setName("王五");
        salesEmployee.setMonth(5);
        salesEmployee.setSales(3000);
        salesEmployee.setRate(0.75);
        salesEmployee.getSalary(8);

        BasePlusSalesEmployee basePlusSalesEmployee=new BasePlusSalesEmployee();

        Employee[] employee=new Employee[3];
        employee[0]=salariedEmployee;
        employee[1]=hourlyEmployee;
        employee[2]=salesEmployee;
        //employee[3]=basePlusSalesEmployee;
        for (int i = 0; i < employee.length; i++) {
            employee[i].getSalary(8);
        }
    }
}
class Employee{                             //所有员工的父类
    private String name;                    //姓名
    private int month;                      //生日

    /**根据月份来计算工资，如果过生日则奖励100元*/
    public void getSalary(int month){
        if (getMonth()==month){
            System.out.println("这个月是你的生日奖励100元，总共:"+"元");
        }else{

        }

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }
}

class SalariedEmployee extends Employee{    //固定工资的员工
    private double salary;                  //月薪

    /**方法的重写，计算工资*/
    public void getSalary(int month){

        if (super.getMonth()==month){
            System.out.println(this.getName()+month+"月是你的生日奖励100元，总共:"+(this.salary+100)+"元");
        }else{
            System.out.println(this.getName()+month+"的工资:"+this.salary+"元");
        }

    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

}


class HourlyEmployee extends Employee{      //按小时拿工资的员工
    private double hourlySalary;            //每小时的工资
    private int hours;                      //每月工作的小时数

    /**方法的重写，计算工资*/
    public void getSalary(int month){

        if (getHourlySalary()>160){                //每个月超出160小时的部分按照1.5倍发放

            if (super.getMonth()==month){
                System.out.println("这个月是你的生日奖励100元，总共:"+(this.hours*this.hourlySalary*1.5+100)+"元");
            }else{
                System.out.println("这个月是你的生日奖励100元，总共:"+(this.hours*this.hourlySalary+100)+"元");
            }
        }else{
            System.out.println(this.getName()+month+"月的工资:"+this.hours*this.hourlySalary+"元");
        }

    }

    public double getHourlySalary() {
        return hourlySalary;
    }

    public void setHourlySalary(double hourlySalary) {
        this.hourlySalary = hourlySalary;
    }

    public int getHours() {
        return hours;
    }

    public void setHours(int hours) {
        this.hours = hours;
    }

}


class SalesEmployee extends Employee{       //工资由月销售额和提成率决定
    private double sales;                   //月销售额
    private double rate;                    //提升率

    /**方法的重写，计算工资*/
    public void getSalary(int month){
        System.out.println(this.getName()+month+"月的工资是"+this.sales*this.rate);

    }

    public double getSales() {
        return sales;
    }

    public void setSales(double sales) {
        this.sales = sales;
    }

    public double getRate() {
        return rate;
    }

    public void setRate(double rate) {
        this.rate = rate;
    }
}


class BasePlusSalesEmployee extends SalesEmployee{  //有固定底薪的销售人员，工资有底薪加上销售额的提成部分
    private double baseSalary;              //底薪

    /**方法的重写，计算工资*/
    public void getSalary(int month){

        if (super.getMonth()==month){
            System.out.println(this.getName()+month+"月是你的生日奖励100元，总共:"+(super.getSales()+this.baseSalary+100)+"元");
        }else{
            System.out.println(this.getName()+month+"月的工资:"+super.getSales()+this.baseSalary+"元");
        }

    }

    public double getBaseSalary() {
        return baseSalary;
    }

    public void setBaseSalary(double baseSalary) {
        this.baseSalary = baseSalary;
    }

}